@extends('layout.app') @section('content')

    <div class="box-body">

        <table id="rowed3"></table>
        <div id="prowed3"></div>

    </div>

    <script>
        $(document).ready(function() {

            var data = {
                url: "/agent/zongdai/translog",
                postData: postData(),
                colNames: ['时间', '合伙人', '伙伴','转账前','转账后', '金额','备注', '状态'],
                colModel: [{
                    name: 'create_time',
                    formatter:'date',
                    formatoptions: {srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s'},
                    searchoptions: {
                        sopt: ['lt', 'le', 'gt', 'ge'],
                        dataInit : function (elem) {
                            $(elem).datepicker({
                                dateFormat: 'yy-mm-dd',
                                monthNames: ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
                                dayNamesMin: ['日','一','二','三','四','五','六'] });
                        }
                    }
                }, {
                    name: 'chao_id',
                    title:false,
                    formatter: function(cellvalue, options, object) {
                        return '<b title="'+cellvalue+'">'+object.chaoz_name+'</b>';
                    }
                }, {
                    name: 'zongdai_id',
                    title:false,
                    formatter: function(cellvalue, options, object) {
                        return '<b title="'+cellvalue+'">'+object.zongdai_name+'</b>';
                    }
                }, 
                {
                    name: 'before',
                    search: false,
                    sortable: false,
                    formatter: function(cellvalue) {
                        return cellvalue / 100;
                    }
                }, {
                    name: 'after',
                    search: false,
                    sortable: false,
                    formatter: function(cellvalue) {
                        return cellvalue / 100;
                    }
                },
                 {
                    name: 'trans_money',
                    formatter: function(cellvalue) {
                        if (cellvalue > 0) {
                            return '<span class="text-danger"></i> ' + cellvalue/100 + '</span>';
                        } else {
                            return '<span class="text-success"></i> ' + cellvalue/100 + '</span>';
                        }
                    }
                }, {
                    name:'desc',
                    search: false,
                    formatter: function(cellvalue, options, object) {
                        if(object.zongdai_id == 0) {
                            return '['+object.chaoz_name+']保险箱转账余额';
                        }
                        if (object.trans_money*1 > 0) {
                            return '['+object.chaoz_name+']向['+object.zongdai_name+']转账';
                        } else {
                            return '['+object.zongdai_name+']向['+object.chaoz_name+']转账';
                        }
                    }
                },{
                    name: 'is_set',
                    sortable: false,
                    stype: 'select',
                    searchoptions: {
                        sopt: ["eq", "ne"],
                        value: "0:转账提交成功;1:转账成功;2:余额不足;3:伙伴余额不足"
                    },
                    formatter: function(cellvalue, options, object) {
                        cellvalue = cellvalue.toString();
                        switch (cellvalue) {
                            case "0":
                                return "<span class='text-active'>转账提交成功</span>";
                            case "1":
                                return "<span class='text-success'>转账成功</span>";
                            case "2":
                                if (object.zongdai_id == 0) {return "<span class='text-info'>保险箱余额不足</span>";} else {
                                    return "<span class='text-info'>余额不足</span>";
                                }
                                
                            case "3":
                                if(object.zongdai_id == 0) {
                                    return "<span class='text-warning'>余额不足</span>";
                                }else {
                                    return "<span class='text-warning'>伙伴余额不足</span>";
                                }
                        }
                        return cellvalue;
                    }

                }],
                caption: '<i class="fa fa-table"></i> {{$label2}}',
                sortname: 'id',
                sortorder: "desc",
            };

            jqGrid(data);
        });

        function postData() {
            return {
                @if($request->get("user_id"))
                user_id: '{{$request->get("user_id")}}',
                @endif
                @if($request->get("type"))
                type: '{{$request->get("type")}}',
                @endif
            }
        }
    </script>

@endsection